package com.oak.interviewdemo.sys.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oak.interviewdemo.common.AbstractController;
import com.oak.interviewdemo.sys.entity.User;
import com.oak.interviewdemo.sys.service.IUserService;
import com.oak.interviewdemo.utils.page.PageR;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author guoxy
 * @since 2020-05-10
 */
@RestController
@RequestMapping("/sys/user")
@Api(value = "/sys/user", tags = "用户管理接口")
public class UserController extends AbstractController {

    @Autowired
    private IUserService userService;

    @PostMapping("/list")
    @ApiOperation(value = "用户信息分页查询", notes = "用户信息分页查询(-)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页数", required = false, dataType = "Integer", defaultValue = "1"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = false, dataType = "Integer", defaultValue = "20")
    })
    public PageR findPage(Integer current, Integer pageSize, User user) {
//        IPage<User> iPage = userService.selectUserPage(pageSize, current, user);
        user.setUsername("");
        IPage<User> iPage = userService.selectUserPage(1, 10, user);
        return PageR.putData(iPage);
    }

    @PostMapping("/demo")
    @ApiOperation(value = "测试", notes = "测试(-)")
    public String demo() {
        return "返回成功!success!";
    }
}
